// 手动实现call函数 
// https://segmentfault.com/a/1190000022279193
Function.prototype.newCall = function(context){
    if(typeof this !== 'function' ){
        throw new TypeError('error')
    }
    context = context || window
    context.fn = this   
    const arg = [...arguments].slice(1)
    const result = context.fn(...arg)
    delete context.fn;
    return result 
}

function Product(name,price){
    this.name = name
    this.price = price
}

function Foods(name,price,categrey){
    Product.newCall(this,name,price)
    this.categrey = categrey;
}

console.log(Function.length)   //1
console.log((new Foods("dushenyan",18,"log times")).name)